<template>
  <div class="bottom">
    <div class="right">
      <div class="right-top">
        <h1>喜欢的商品</h1>
      </div>
      <div class="right-end" v-if="token !== ''">
        <ul class="right-ul">
          <li class="right-li" v-for="item in data" :key="item.id">
            <div class="right-sp">
              <img :src="item.src" alt="" />
              <h3>{{ item.General }}</h3>
              <h2>{{ item.theprice }}</h2>
              <p></p>
              <div class="actions">
                <a class="bin" @click="delLickData(item.id)">删除</a>
                <a class="bint" @click="getDetailed(item.id)">查看详情</a>
              </div>
            </div>
          </li>
        </ul>
      </div>
      <div class="right-end" v-if="token === ''">
        <div class="IsLogin">请先登录</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  created() {
    const savedToken = localStorage.getItem('token');
    if (savedToken) {
      this.token = savedToken;
    } else {
      this.token = '';
    }
  },
  data: {
    return() {
      return {
        token: '',
      }
    },
  },
  props: {
    data: {
      type: Array,
      default() {
        return [];
      },
    },
  },
  methods: {
    //将删除商品的id传个父组件
    delLickData(id) {
      // console.log(id);
      this.$emit("delLickData", id);
    },
    //查看详情传id
    getDetailed(id) {
      this.$emit("getDetailed", id);
    }
  }
}
</script>

<style scoped>
.IsLogin {
  width: 120px;
  color: #666;
  margin: 0 auto;
  font-size: 25px;
}

.bottom {
  cursor: pointer;
  margin: 0 auto;
  background: #f5f5f5;
  width: 1240px;
  height: 100%;
  display: flex;
  padding-bottom: 40px;
  justify-content: space-around;
}

.left {
  margin: 0 auto;
  background: #fff;
  width: 234px;
  height: 600px;
}

.leftbox {
  margin: 0 48px 12px;
  padding: 16px 0;
}

.leftbox h3 {
  font-size: 16px;
  font-weight: 400;
  line-height: 52px;
  color: #333;
  margin: 0;
  padding: 0;
}

.list {
  list-style: none;
}

.list li {
  padding: 3px 0;
  cursor: pointer;
  color: #666;
}

.list li:hover {
  color: #ff6700;
}

.right {
  margin: 0 auto;
  background: #fff;
  width: 978px;
  /* height: 1000px; */
}

.right-top {
  padding: 36px 48px;
}

.right-top h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 400;
  line-height: 68px;
  color: #757575;
}

.right-end {
  padding: 36px 48px;
}

.right-ul {
  width: 930px;
  margin: 0;
  padding: 0;
  list-style-type: none;
}

.right-li {
  float: left;
  width: 260px;
  height: 348px;
  padding-top: 40px;
  padding-right: 48px;
  border-bottom: 1px solid #e0e0e0;
  text-align: center;
}

.right-sp img {
  width: 200px;
  height: 200px;
}

.right-sp h2 {
  margin: 0 0 10px;
  color: #ff6700;
}

.right-sp p {
  height: 18px;
}

.right-li:hover .actions {
  opacity: 1;
}

.actions {
  width: 260px;
  height: 30px;
  opacity: 0;
  transition: opacity 0.8s ease;

}

.bin {
  width: 110px;
  height: 30px;
  display: inline-block;
  margin: 0 7px;
  font-size: 12px;
  border: 1px solid #b0b0b0;
  line-height: 28px;
  color: #666;
  transition: 0.8s ease;
}

.bin:hover {
  color: #fff;
  background: #757575;
}

.bint {
  width: 110px;
  height: 30px;
  display: inline-block;
  margin: 0 7px;
  font-size: 12px;
  line-height: 28px;
  background: #ff6700;
  color: #fff;
}
</style>